//
//  BuyPointsViewController.m
//  phmall
//
//  Created by admin on 2017/11/14.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "BuyPointsViewController.h"
#import "IntegralView.h"
@interface BuyPointsViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(strong,nonatomic)UITableView *myTableview;
@end

@implementation BuyPointsViewController
-(void)rightBarAction{
    
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navBarBgAlpha=@"1.0";
    //    // 改变NavBar顶层View的颜色
    self.navigationController.navigationBar.barTintColor =  [UIColor whiteColor];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem*  rightBar=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"帮助"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(rightBarAction)];
    
    self.navigationItem.rightBarButtonItem=rightBar;
    
    UIBarButtonItem* leftBar=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(leftBarAction)];
    self.navigationItem.leftBarButtonItem=leftBar;
    
    [self.view addSubview:self.myTableview];
    [self.myTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(0);
        make.left.right.equalTo(self.view).priorityHigh();
        make.bottom.equalTo(self.view).with.offset(0).priorityHigh();
    }];
    
    UIView *headerView=[UIView new];
    headerView.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UIView *head=[[UIView alloc]init];
    head.backgroundColor=[UIColor whiteColor];
    [headerView addSubview:head];
    [head mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(SCREEN_WIDTH).priorityHigh();
        make.left.offset(0);
        make.height.offset(44);
        make.top.offset(10);
        
    }];
    
    UILabel *fill=[[UILabel alloc]init];
    fill.font=[UIFont systemFontOfSize:13];
    fill.textColor=[UIColor colorWithHexString:@"#adadad"];
    fill.text=@"请输入充值金额(₱):";
    [head addSubview:fill];
    
    [fill mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
//        make.right.equalTo(money.mas_left).offset(-10);
        make.centerY.offset(0);
    }];
    
    UITextField *money=[[UITextField alloc]init];
    money.font=[UIFont systemFontOfSize:13];
    money.keyboardType=UIKeyboardTypeNumberPad;
    [head addSubview:money];
    [money mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.left.equalTo(fill.mas_right).offset(10);
        make.height.offset(40);
        make.centerY.offset(0);
    }];
    
    IntegralView *integral=[[IntegralView alloc]init];
    [headerView addSubview:integral];
    [integral mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(head);
        make.height.offset(310);
        make.top.equalTo(head.mas_bottom).with.offset(1);
       
    }];
    [integral layoutIfNeeded];
    
    UIImageView *img=[[UIImageView alloc]init];
    img.backgroundColor=[UIColor orangeColor];
    [headerView addSubview:img];
    ViewBorderRadius(img, 5, 0, [UIColor clearColor]);
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(10);
        make.left.offset(10);
        make.top.equalTo(integral.mas_bottom).offset(15);
    }];
    
    UILabel *hint=[[UILabel alloc]init];
    hint.font=[UIFont systemFontOfSize:13];
    hint.text=@"提示:7₱可兑换5积分,满100送20哦~~~";
    [headerView addSubview:hint];
    [hint mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(img.mas_right).offset(5);
        make.centerY.equalTo(img);
    }];
    
    UIButton *recharge=[UIButton buttonWithType:UIButtonTypeCustom];
    [headerView addSubview:recharge];
    [recharge setBackgroundImage:[UIImage imageNamed:@"背景渐变条"] forState:UIControlStateNormal];
    [recharge setTitle:@"立即充值" forState:UIControlStateNormal];
    [recharge addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
    [recharge setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //    login.backgroundColor=[UIColor colorWithHexString:@"#ff9300"];
    //    ViewBorderRadius(login, 5, 1, [UIColor colorWithHexString:@"#ff9300"]);
    [recharge mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(hint.mas_bottom).offset(15);
        make.height.offset(44);
        make.left.offset(20).priorityHigh();
        make.right.offset(-20).priorityHigh();
        make.bottom.offset(-10);
    }];
    
    CGFloat height = [headerView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    CGRect frame = headerView.bounds;
    frame.size.height = height;
    headerView.frame = frame;
    [self.myTableview setTableHeaderView:headerView];
    // Do any additional setup after loading the view.
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"newCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;;
    }
    cell.opaque=YES;
    cell.layer.drawsAsynchronously=YES;
    cell.layer.rasterizationScale=[UIScreen mainScreen].scale;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //分割线补全
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//MARK:-GETTER
- (UITableView *)myTableview{
    if (!_myTableview) {
        _myTableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _myTableview.delegate = self;
        _myTableview.dataSource = self;
        _myTableview.backgroundColor=[UIColor groupTableViewBackgroundColor];
        _myTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _myTableview.showsVerticalScrollIndicator=NO;
        //        _myTableview.emptyDataSetSource=self;
        //        _myTableview.emptyDataSetDelegate=self;
        _myTableview.scrollEnabled = YES;
    }
    return _myTableview;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
